from config import ini_op
import json, requests, pandas, duckdb, os
from time import strftime
from utils.path_utils import get_project_root
from database.duckdb.duckdb_base import get_connection


def run():
  timenow = str(strftime("%Y%m%d%H%M%S"))

  conn = get_connection()
  #指定列创建新表
  conn.execute("""
      delete from t_api_bm where fiyear = 'kjnd';
      insert into t_api_bm (
        id,
        code,
        name_chs,
        fullname_chs,
        accorgid,
        orgcode,
        orgname,
        admindeptid,
        treeinfo_isdetail,
        treeinfo_layer,
        treeinfo_path,
        parentid,
        isdisable,
        disableyear,
        sortorder,
        fiyear,
        timestamp_createdon,
        timestamp_lastchangedon,
        esun_api_update)
      select Gsdm||'-'||Bmdm,Bmdm,Bmmc,Bmmc,Gsdm,Gsdm,Gsdm,'对应组织结构内码','1',1,
        '分级码',null,Syzt,null,null,'kjnd',STRPTIME(Jl_RQ, '%Y%m%d'),STRPTIME(Xg_RQ, '%Y%m%d'),'"""+timenow+"""'
      from PubBmxx;
      """)
  conn.close()